cmake_minimum_required (VERSION 3.15)

project (DemoUI C CXX)

#显示编译过程
set (CMAKE_VERBOSE_MAKEFILE off)

# 设置编译工具
# set(CMAKE_CXX_COMPILER g++)
# set(CMAKE_C_COMPILER gcc)

# 指定C/C++ 版本
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)

# 手动指定编译类型
# SET(CMAKE_BUILD_TYPE "Debug")

# 添加编译参数
# add_compile_options(-Og -ggdb)                               # 编译选项
# add_compile_definitions(ARM_MATH_CM4;ARM_MATH_MATRIX_CHECK)  # 宏定义
# add_definitions()                                            # 宏定义
# set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Wno-register")        # C参数
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-register")      # C++参数
# add_link_options()                                          # 链接参数

# 设置执行文件输出路径
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/out)
# 设置静态库输出路径
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/out/bin/)

set(includeFolder)
set(libList)
set(libdirList ${PROJECT_SOURCE_DIR}/out/bin)

# 设置本地安装库
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} $ENV{LOCAL_LIB_PATH})
set(CMAKE_PREFIX_PATH $ENV{LOCAL_LIB_PATH})

#####################################
# YAML-CPP
#####################################
find_package(yaml-cpp REQUIRED)
link_directories(${YAML_CPP_LIBRARY_DIR})   # why i need to add this?
include_directories(${YAML_CPP_INCLUDE_DIR})
set(libList ${libList} ${YAML_CPP_LIBRARIES})

#####################################
# 添加子文件夹
#####################################
add_subdirectory(UserInterface)
add_subdirectory(CommonUIImp)
add_subdirectory(Code)

include_directories(${includeFolder})

if("${UNIT_TEST}" STREQUAL "True")
    add_subdirectory(UnitTest)
else()
    aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} mainSrc)
    add_executable(main ${mainSrc})
    target_link_libraries(
        main
        ${libList}
    )
endif()
